package com.example.home.attorney.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import com.bumptech.glide.Glide;
import com.example.home.R;
import com.example.home.attorney.bean.MeConsultBean;
import com.google.gson.Gson;

public class MeConsultDateil extends AppCompatActivity {

    private MeConsultBean.RowsBean rowsBean;
    private ImageView back;
    private ImageView txImg;
    private TextView lawyerName;
    private TextView workStartAt;
    private TextView legalExpertiseName1;
    private TextView stater;
    private TextView legalExpertiseName;
    private TextView content;
    private TextView phone;
    private ImageView imageUrls;
    private Button btnEvaluate;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_me_consult_dateil);
        Intent intent = getIntent();
        if(intent != null) {
            String meconsultD = intent.getStringExtra("meconsultD");
            if(meconsultD != null) {
                Gson gson = new Gson();
                rowsBean = gson.fromJson(meconsultD, MeConsultBean.RowsBean.class);
            } else {
                // 处理meconsultD为null的情况
            }
        }


        initView();
        getData();

        getConsultData();
    }

    private void getConsultData() {
        String state = rowsBean.getState();
        if ("0".equals(state)){
            stater.setText("未受理");
        }else if ("1".equals(state)){
            stater.setText("已受理");
        }
        legalExpertiseName.setText(rowsBean.getLegalExpertiseName());
        content.setText(rowsBean.getContent());
        phone.setText(rowsBean.getPhone());
        Glide.with(MeConsultDateil.this).load(rowsBean.getImageUrls()).into(imageUrls);
    }


    private void getData() {
        lawyerName.setText(rowsBean.getLawyerName());
        workStartAt.setText(rowsBean.getCreateTime());

        legalExpertiseName1.setText(rowsBean.getLegalExpertiseName());
    }

    private void initView() {

        back = findViewById(R.id.back);
        txImg = findViewById(R.id.tx_img);
        lawyerName = findViewById(R.id.lawyerName);
        workStartAt = findViewById(R.id.workStartAt);
        legalExpertiseName1 = findViewById(R.id.legalExpertiseName1);
        stater = findViewById(R.id.state);
        legalExpertiseName = findViewById(R.id.legalExpertiseName);
        content = findViewById(R.id.content);
        phone = findViewById(R.id.phone);
        imageUrls = findViewById(R.id.imageUrls);
        btnEvaluate = findViewById(R.id.btn_evaluate);



        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MeConsultDateil.this.finish();
            }
        });

        btnEvaluate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(MeConsultDateil.this,ScoreActivity.class);
                intent.putExtra("meAttorId",String.valueOf(rowsBean.getId()));
                startActivity(intent);
            }
        });


    }

}